﻿<UserControls1:ScrumItemControlBase x:Class="ScrumTable.UI.View.WinTouch.UserControls.TaskControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" xmlns:CustomControl="clr-namespace:ScrumTable.UI.View.CustomControl;assembly=ScrumTable.UI.View" xmlns:PieChart="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.PieChart" xmlns:UserControls1="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:Localization="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View" xmlns:CustomControl1="clr-namespace:ScrumTable.UI.View.WinTouch.CustomControl" xmlns:ShaderEffectLibrary="clr-namespace:ShaderEffectLibrary;assembly=ScrumTable.UI.View" xmlns:Controls="clr-namespace:ScrumTable.UI.View.Controls;assembly=ScrumTable.UI.View" xmlns:Controls1="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.HtmlRichText.Controls" s:SurfaceDragDrop.Drop="OnTaskDrop" s:SurfaceDragDrop.PreviewQueryTarget="OnTaskPreviewQueryTarget" AllowDrop="True"
    TouchDown="OnUserStoryPreviewContactDown" MouseDown="OnTaskMouseDown" x:Name="TaskRoot">
    <UserControl.Resources>        
        <Converter:ConverterIsNullVisibility x:Key="ConverterIsNullVisibility"/>        
        <Converter:ConverterBoolVisibility x:Key="ConverterIsVisible"/>
        <Converter:ConverterPriorityBrush x:Key="ConverterPriorityColor"/>        
    </UserControl.Resources>
    
    <Grid>
        <!-- Star with Estimate at the right top -->
        <Grid VerticalAlignment="Top" HorizontalAlignment="Right" Panel.ZIndex="1" Width="25" Height="25">
            <UserControls1:StarControl Panel.ZIndex="1" VerticalAlignment="Top" StrokeBrush="Black" FillBrush="{x:Null}"/>

            <Label Panel.ZIndex="3" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black" FontSize="10" FontWeight="Bold" Content="{Binding Path=RemainingWork}" />                        
            <PieChart:SimplePieChart Panel.ZIndex="0" Opacity="1" FirstColor="#7FFF7F" SecondColor="#FF7F7F" BackColor="#7FFF7F" FirstValue="{Binding Path=CompletedWork, Mode=OneWay}" SecondValue="{Binding Path=RemainingWork, Mode=OneWay}" Width="21" Height="21" VerticalAlignment="Center" HorizontalAlignment="Center" />
        </Grid>

        <!-- Task Symbol left-->
        <Grid Panel.ZIndex="1" Width="20" Height="20" Margin="3,3,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">            
            <CustomControl:StateIcon State="{Binding State}" Icon="IconTask"/>
        </Grid>


        <!-- Member Image left -->
        <Grid Panel.ZIndex="1" Visibility="{Binding Path=AssignedMember, Converter={StaticResource ConverterIsNullVisibility}}" VerticalAlignment="Bottom" HorizontalAlignment="Right">
             <Border BorderThickness="2" Background="White" BorderBrush="{Binding AssignedMember.Color}">
                <CustomControl:WebAsyncReportMemberImage  UriBitmap="{Binding AssignedMember.Picture}" MaxHeight="25" MaxWidth="25"></CustomControl:WebAsyncReportMemberImage>
            </Border>
        </Grid>

        <Border BorderBrush="#FF000000" Name="TaskBorder" BorderThickness="2,2,2,2" CornerRadius="2,2,2,2" Margin="12,7,7,7" VerticalAlignment="Stretch" Background="{StaticResource TaskOrange}">
            <Grid x:Name="DropRoot"  >                
                <TextBlock   Padding="0"  VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,16,-3,0">
                    <TextBlock.Text>
                        <Binding StringFormat="# {0}" Path="BackEndId"/>
                    </TextBlock.Text>                    
                    <TextBlock.LayoutTransform>
                        <RotateTransform Angle="90"/>
                    </TextBlock.LayoutTransform>
                </TextBlock>

                <CustomControl1:ScrumTableScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" x:Name="ScrollDetail">
                    <StackPanel Orientation="Vertical" Margin="12,2,0,0">
                        <Label   x:Name="NameLabel" Margin="-11,-1,10,0" HorizontalContentAlignment="Left" Padding="11,3,9,5" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=FontSize}" Background="{Binding [Priority], Converter={StaticResource ConverterPriorityColor}}">
                            <TextBlock TextBlock.FontWeight="Bold"  TextWrapping="WrapWithOverflow"  TextAlignment="Left" Text="{Binding Name}">                                
                            </TextBlock>
                        </Label>

                        <Border BorderBrush="Black" BorderThickness="0,1,0,0" Margin="0,0,10,0" Padding="0" HorizontalAlignment="Stretch" Visibility="{Binding ElementName=TaskRoot, Path=IsPlaceForAddInfo, Converter={StaticResource ResourceKey=ConverterIsVisible}}">
                            <StackPanel  HorizontalAlignment="Stretch">
                                <!--
                                <Label Margin="0,0,0,0" Padding="0">
                                    <Localization:Translate Uid="Task_Description" Default="[Description]" />
                                </Label>
                                -->
                                <UserControl Margin="0,0,0,0" Padding="0"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                                    <Grid >
                                        <Rectangle Fill="White" Opacity="0.5">
                                        </Rectangle>
                                        <Controls1:RichTextHtmlBox Panel.ZIndex="10" Margin="2" Text="{Binding Description, Mode=OneWay}" IsHtml="{Binding IsDescriptionHtml}"/>
                                        <!--
                                        <TextBlock Padding="2" TextWrapping="WrapWithOverflow" Text="{Binding Path=Description}" TextAlignment="Left">
                                        </TextBlock>
                                        -->
                                    </Grid>
                                </UserControl>
                            </StackPanel>
                        </Border>
                    </StackPanel>
                </CustomControl1:ScrumTableScrollViewer>
            </Grid>
        </Border>
    </Grid>
</UserControls1:ScrumItemControlBase>
